<template>
  <router-view v-slot="{ Component }">
    <component :is="Component" />
  </router-view>
</template>
<script setup>
import api from '@/api'
import { upload } from '@/libs/ali'
window.ocrCarNumber = async () => {
  try {
    const key = await upload(window.android.getOcrBase64(), 'ocrCarNumber')
    const res = await api.ocrCarNumber({
      imageUrl: `${import.meta.env.VITE_INNER_FILE_DOMAIN}${key}`
    })
    if (res.data) {
      localStorage.ocrCarNumber = res.data
      const order = await api.carNumberToOrderId({ number: res.data })
      if (order.data && order.data.length) {
        window.android.onOcrResult('1', `车辆 ${res.data} 已上磅`, order.data[0].id + '')
      } else {
        window.android.onOcrResult('2', '', '')
      }
    } else {
      window.android.onOcrResult('3', '', '')
    }
  } catch (e) {
    console.error(e)
    window.android.onOcrResult('3', '', '')
  }
}
</script>
<style lang="scss">
html {
  width: 100%;
  height: 100%;
  body {
    width: 100%;
    height: 100%;
    margin: 0;
    #app {
      width: 100%;
      height: 100%;
      overflow: hidden;
      input {
        outline: none;
      }
    }
  }
}
</style>
